const mongoose = require('mongoose');
mongoose
  .connect('mongodb+srv://liujianlong323:Aa010205%23@cluster0.fbrfngl.mongodb.net/React')
  .then(() => {
    console.log('连接成功');
  })
  .catch((err) => {
    console.log(err);
  });
// 模板
// const worksSchema = new mongoose.Schema({
//   name: String,
//   state: Number,
//   Time: {
//     type: Date,
//     default: Date.now
//   },
//   isCheck: {
//     type: Boolean,
//     default: false,
//   },
//   children: [{
//     name: String,
//     date: { type: Date, default: Date.now }
//   }],
// });
// const worksModel = mongoose.model('works', worksSchema, 'works');

// 用户留言
const usersSchema = new mongoose.Schema({
  usersname: String,
  password: String,
});
const usersModel = mongoose.model('users', usersSchema, 'users');

const schoolInfoSchema = new mongoose.Schema({
  name: String,
  address: String,
  img: String,
  type: String,
});

const schoolInfoModel = mongoose.model('schoolInfo', usersSchema, 'schoolInfo');

//投诉
const complaintSchema = new mongoose.Schema({
  name: String,
  school: String,
  title: String,
  content: String,
  time: String,
  type: String,
  user: String,
  images: {
    type: Array,
    default: [],
  },
  videos: {
    type: Array,
    default: [],
  },
});
const complaintModel = mongoose.model(
  'complaint',
  complaintSchema,
  'complaint',
);

//唐佑超
let xm1 = new mongoose.Schema({
  name: String,
  children1: [
    //洗消区
    {
      name1: String, //清洗水果
      img1: String, //清洗水果
    },
  ],
});
const xmmodel = mongoose.model('xm', xm1, 'xm');

// 用户身份表
const UserIdentitySchema = new mongoose.Schema({
  name: String,
});

const UserIdentityModel = mongoose.model(
  'UserIdentity',
  UserIdentitySchema,
  'UserIdentity',
);

// 反馈问题表
const FeedbackIssueSchema = new mongoose.Schema({
  conText: String,
  img: String,
  phone: String,
  cate: {
    type: mongoose.Types.ObjectId,
    ref: 'UserIdentity',
  },
});
const FeedbackIssueModel = mongoose.model(
  'FeedbackIssue',
  FeedbackIssueSchema,
  'FeedbackIssue',
);

// 卫生检查模型表
const HygieneSchema = new mongoose.Schema({
  title: String, // 例如(食堂厨房日常卫生检查)
  content: String, // 检查后的反馈内容
  imgUrl: String, // 检查后的反馈图片(使用随机图片)
  HyPeron: String, // 检查人(随机生成)
  HyBento: String, // 检查部门(随机生成)
  CheckTime: Date, // 检查时间
});
// 高文晗
const HygieneModel = mongoose.model('Hygiene', HygieneSchema, 'Hygiene');
// 杨佳乐   个人中心页
const VPCC = new mongoose.Schema({
  imags: String, //头像
  NickName: String, //昵称
  name: String, //姓名
  telplate: String, //手机号
  sex: String, //性别
  childName: String, //孩子姓名
  ChildtTes: String, //孩子关系
});
const VPCCmodel = mongoose.model('VPCC', VPCC, 'VPCC');

// 抽检公示
const AcceptanceSchema = new mongoose.Schema({
  title: String,
  imgUrl: Array,
  content: String,
  supplier: String,
  address: String,
  checkSelect:Array,
  checker: String,
  checkTimer: Date,
});

const AcceptanceModel = mongoose.model(
  'Acceptance',
  AcceptanceSchema,
  'Acceptance',
);


const  waterSchema = new mongoose.Schema({
    name: String,  //供应商名称
    address: String,   // 地址
    prople: String,   // 负责人
    tel: String,   //电话
    flloer: String,   //介绍
})
const waterModel = mongoose.model('water', waterSchema, 'water')
module.exports = {
  // worksModel,
  usersModel,
  complaintModel,
  schoolInfoModel,
  UserIdentityModel,
  FeedbackIssueModel,
  xmmodel,
  VPCCmodel,
  waterModel,
  HygieneModel,
  AcceptanceModel
};
